package nancal.mp.model

import nancal.mp.db.mongo.JenkinsLanguageEnum
import nbcp.base.comm.StringMap
import java.time.LocalDateTime


open class K8sAppServiceInfo constructor(
    var name: String = "",
    var language: JenkinsLanguageEnum = JenkinsLanguageEnum.Normal,
    var languageVersion: String = "",
    var fullImageVersion: String = "",
    var replicas: Int = 0,
    var readyReplicas: Int = 0,


    //deployment生成的 appName 标签, 如果没有= container.name
    var appName: String = "",
    var envs: StringMap = StringMap()
) {

    val imageVersion: String
        get() {
            var sects = fullImageVersion.split("/").last().split(":")
            if (sects.size > 1) {
                return sects.last()
            }
            return "";
        }
//    var imageVersion: String = "",
}

open class K8sAppServiceStatusInfo constructor(
    var name: String = "",
    var imageHost:String = "",
    var imageNameVersion: String = "",
    var replicas: Int = 0,
    var readyReplicas: Int = 0,
    var isLatestRsVersion: Boolean = false,
    var lastEvent: K8sEventData = K8sEventData()
)

data class K8sEventData(var reason: String = "", var eventAt: LocalDateTime = LocalDateTime.now())